package copyfile02;

import java.io.*;

/**
 * 利用BufferedInputStream和BufferedOutputStream做文件拷贝
 */
public class BufferedCopy01 {
	public static void main(String[] args) throws IOException {
		//1.利用FileInputStream关联文件,再利用BufferedInputStream包装FileInputStream,提高读取效率
		BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day23/风景.jpg"));

		//2.利用FileOutputStream关联文件,再利用BufferedOutStream包装FileOutStream,提高写入效率
		BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("day23/风景_copy_3.jpg"));

		//3.循环读写
		int b;
		while((b=bis.read())!=-1){
			bos.write(b);
			//bos.flush();
		}
		//4.关流释放资源
		bis.close();
		bos.close();
	}
}
